package lesson;

import java.sql.*;

public class JDBCDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.jdbc.Driver");

        String url = "jdbc:mysql:///db1?useSSL=false";
        String user = "root";
        String psd = "1234";
        Connection connection = DriverManager.getConnection(url,user,psd);

        String id = "2";
        String name ="阿尔萨斯";
        String sql = "select * from account where id = ? and name = ?";

        PreparedStatement psttm = connection.prepareStatement(sql);

        psttm.setString(1,id);
        psttm.setString(2,name);

        ResultSet rs = psttm.executeQuery();

        if(rs.next()){
            System.out.println("登录成功");
        }else{
            System.out.println("登陆失败");
        }

        rs.close();
        psttm.close();
        connection.close();
    }
}
